package com.clkj.xiuzheng.dao.shangcheng;

import com.clkj.xiuzheng.pojo.shangcheng.UserCommission;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

/**
 * @author yawang
 * @create 2024/05/22 14:01:17
 **/
@Repository
public interface UserCommissionMapper extends Mapper<UserCommission> {
//    @Update("if exists (select * from t_xz_usercommission where USER_ID = #{userId}) " +
//            "update t_xz_usercommission set total_money +=#{totalMoney},recharge_num +=1,recharge_money +=#{rechargeMoney} where USER_ID = #{userId}  " +
//            "else insert into t_xz_usercommission values (#{userId},#{totalMoney},#{grantMoney},#{rechargeNum},#{rechargeMoney}) ")
//
    @Update("update t_xz_usercommission set total_money +=#{totalMoney},recharge_num +=1,recharge_money +=#{rechargeMoney} where USER_ID = #{userId}")
    void addOrUpdate(UserCommission commission);

    @Update("update  t_xz_usercommission set grant_money  +=#{totalMoney} where user_id = #{userId}")
    void updateUserCommission(Double totalMoney,Integer userId);
}
